﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace K36_104_047_NguyenVanCaoNguyen
{
    class Usage
    {
        public string ID { get; set; }
        public string Name { get; set; }
    }
    class UsageItemList : List<Usage>
    {
        public UsageItemList()
        {
            SqlConnection conn = new SqlConnection(Properties.Settings.Default.ConnStr);
            SqlCommand cmd = new SqlCommand("SELECT uid, uname FROM Usages", conn);
            conn.Open();
            SqlDataReader r = cmd.ExecuteReader();
            while (r.Read())
            {
                Usage u = new Usage();
                u.ID = r["uid"].ToString();
                u.Name = r["uname"].ToString();
                this.Add(u);
            }
            conn.Close();
        }
    }

    class Type
    {
        public string ID { get; set; }
        public string Name { get; set; }
    }
    class TypeItemList : List<Type>
    {
        public TypeItemList()
        {
            SqlConnection conn = new SqlConnection(Properties.Settings.Default.ConnStr);
            SqlCommand cmd = new SqlCommand("SELECT tid, tname FROM Types", conn);
            conn.Open();
            SqlDataReader r = cmd.ExecuteReader();
            while (r.Read())
            {
                Type u = new Type();
                u.ID = r["tid"].ToString();
                u.Name = r["tname"].ToString();
                this.Add(u);
            }
            conn.Close();
        }
    }
}
